package com.example.hw_demo.config;

import com.example.hw_demo.util.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理
 */
@RestControllerAdvice
public class AllException {

    //全局异常处理方法
    @ExceptionHandler(Exception.class)
    public Result allException(Exception e){
        e.printStackTrace();//异常打印
        return  new Result(505,"全局异常",e.getMessage());
    }
}
